import { NormalColony } from '@/bot/instances/normal/NormalColony';
import { $render } from '@/utils/logger';
import { register, reject } from './api';

register('bootstrap', (command: string, args: string[]) => {
    const [roomName] = args;
    const colony = <NormalColony>Empire.colonies[roomName];
    if (!colony) {
        return $render('找不到殖民地', ConsoleColor.red);
    }
    if (colony.operatingMode !== 'normal') {
        return $render('殖民地已经处于其他操作状态', ConsoleColor.red);
    }
    if (command === 'init') {
        // 激活 spawn 模块，设置 spawn 编号
        if (colony.memory.spawnStage && args[1] !== 'reset') {
            return $render('不能重复激活，若要重置请使用 bootstrap init [room] reset', ConsoleColor.red);
        }
        colony.memory.spawnStage = 1;
        colony.capital.getSpawns()[0].memory.i = 0;
        return $render('成功设置', ConsoleColor.green);
    }
    else {
        return reject();
    }
});